#version 3.0
sources :=
include_dirs :=

objects = $(subst .c,.o, $(sources))
dependencies = $(subst .c,.d,$(sources))

CURRENTDIR := $(shell pwd)

include_dirs += -I $(CURRENTDIR)/include

CC := gcc
CFLAGS := --std=c99 
AR :=ar
ARFLAGS :=rv
INCLUDE = $(include_dirs)

MV := mv -f
RM := rm -f
SED := sed

all: 

include src/module.mk

.PHONY :all

all : libexpression.a
	
%.d : %.c 
	$(CC) -M $(CFLAGS) $(INCLUDE) $< > $@.$$$$; \
		$(SED) 's,\($(notdir $*)\.o[ : ]*,$(dir $@)\1.o $@ : ,g' < $@.$$$$ > $@; \
		$(RM) $@.$$$$

libexpression.a: libexpression.a($(objects))

#the followed code is optional
#libexpression.a(linklist.o):linklist.o
#	$(AR) $(ARFLAGS) $@ $<
#
#libexpression.a(linkstack.o):linkstack.o
#	$(AR) $(ARFLAGS) $@ $<
#
#libexpression.a(reverse_polish.o):reverse_polish.o
#	$(AR) $(ARFLAGS) $@ $<

$(objects) : %.o:%.c
	$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@

.PHONY: clean
clean:
	$(RM) $(objects) *.a

